#if !defined(AFX_CAMERAFRAME_H__5A5F45AD_3A0A_4F07_AC5C_6DC6C1AD9546__INCLUDED_)
#define AFX_CAMERAFRAME_H__5A5F45AD_3A0A_4F07_AC5C_6DC6C1AD9546__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// CameraFrame.h : Header-Datei
//

#include "cameraview.h"
#include "dlgnodelist.h"
#include <fgcamera.h>

// Some conversion parameters
typedef struct
{
  UINT32                ImageFormat;            // Image format
  
  UINT16                XSize;
  UINT16                XSizeMax;
  UINT16                XSizeUnit;
  
  UINT16                YSize;
  UINT16                YSizeMax;
  UINT16                YSizeUnit;
  
  UINT16                XPos;
  UINT16                XPosMax;
  UINT16                XPosUnit;
  
  UINT16                YPos;
  UINT16                YPosMax;
  UINT16                YPosUnit;
  
  UINT16                PktSize;
  UINT8                 PhySpeed;
  UINT32                Trigger;
  UINT32                FrameBufferCount;

  UINT8                 BayerPattern;           // Used bayer pattern
  UINT8                 YIsRawMode;             // Raw mode flag
  UINT8                 Y16Invert;              // Inversmode for Y16
  UINT8                 IsResized;              // Is resized or not
  
  UINT32                DmaFlags;               // Dma flags
}CAMERAPARMS;

/////////////////////////////////////////////////////////////////////////////
// Thread class for a CameraFrame.

class CCameraFrame;

class CCameraThread : public CWinThread
{
protected:
  CCameraFrame         *m_pCameraFrame;
  int                   m_Left,m_Top;

public:
                        CCameraThread(CCameraFrame *pCameraFrame,int Left,int Top);
  virtual BOOL          InitInstance();
  virtual int           ExitInstance();
};

/////////////////////////////////////////////////////////////////////////////
// Class CCameraFrame 

class CCameraFrame : public CFrameWnd
{
protected:

// Attribute
public:
        CStatusBar     *m_pStatusBar;           // Our statusbar
        CFGCamera       m_Camera;               // Our camera we work with
        CCameraView    *m_pView;                // Pointer to our view
        CDialog        *m_pDlgModal;            // Pointer to modal dialog
        CAMERAPARMS     m_CamParms;             // Some parameters...
        CAMERAINFO     *m_pCameraInfo;          // Node lists camera info
        HANDLE          m_hEvent;               // Synchronization Event
        BOOL            m_InitOk;               // Result of initialization
        LONG            m_MemorySize;           // Frame memory size
        DWORD           m_MaxFramesToDisplay;   // Frames to display

        BOOL            m_SettingsValid;        // Camera settings are valid
        BOOL            m_CameraActive;         // Camera active or not
		BOOL			processingMode; //if we're processing the robots

        DWORD           m_StartTime;            // Starttime for acquisition
        DWORD           m_FrameCnt;             // Number of received frames
        DWORD           m_DiscardedCnt;         // Frames not shown
        
        RECT            m_SensorRect;           // Over all sensor rectangle
        RECT            m_OrgRect;              // Original rectangle (EditSettings)
        RECT            m_CameraRect;           // Actual camera rectangle
        RECT            m_ViewRect;             // Displayed rectangle

// Operationen
protected:
        BOOL            WriteBitmap(char* pFilename); // Write a bitmap to disk
        
        BOOL            GetCameraParms(CAMERAPARMS *pCamParms);
        BOOL            SetCameraParms(CAMERAPARMS *pCamParms);
        void            UpdateModePane();
        void            OnNewFrame();
        BOOL            DoResize(RECT *pRect); 
        void            UpdateRectangleInfo();
        
public:
        void            SetViewSize(UINT32 Width,UINT32 Height);

        BOOL            Start(int Left,int Top);
        void            Stop();

	//{{AFX_VIRTUAL(CCameraFrame)
	public:
	//}}AFX_VIRTUAL

	                CCameraFrame(CAMERAINFO *pCameraInfo); 
	virtual         ~CCameraFrame();
	
	virtual void    PostNcDestroy() { }      // No self delete!!!

protected:

	//{{AFX_MSG(CCameraFrame)
	afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
	afx_msg void OnClose();
	afx_msg void OnEditsettings();
	afx_msg void OnRun();
	afx_msg void ProcessRobots();
	afx_msg void On160x120();
	afx_msg void On320x240();
	afx_msg void On1024x768();
	afx_msg void On1280x960();
	afx_msg void On640x480();
	afx_msg void On800x600();
	afx_msg void OnFeature();
	afx_msg void On1600x1200();
	afx_msg void OnUsersize();
	afx_msg void OnSave();
	afx_msg void OnScrollmode();
	afx_msg void OnDirectAccess();
	afx_msg void OnAbout();
        afx_msg LRESULT OnFgNotify(WPARAM,LPARAM);
        afx_msg LRESULT OnSelection(WPARAM,LPARAM);
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
public:
        afx_msg void OnOthersLicenseRequest();
        afx_msg void OnOthersLicenseInfo();
};

/////////////////////////////////////////////////////////////////////////////

//{{AFX_INSERT_LOCATION}}

#endif // AFX_CAMERAFRAME_H__5A5F45AD_3A0A_4F07_AC5C_6DC6C1AD9546__INCLUDED_
